import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/pages/ye_xiu/login/actions.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/login/main.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/main.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class GenderSelectWidget extends StatelessWidget {
  const GenderSelectWidget({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(converter: (store) {
      return AppStateViewModel(state: store.state,
        yeXiuStateViewModel: YeXiuStateViewModel(loginStateViewModel: LoginStateViewModel(inputSex: (sex){
          inputSex(store, sex);
        }))
      );
    }, builder: (context, vm) {
      int sex = vm.state.yeXiuState.loginState.sex;
      return Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Expanded(
              flex: 1,
              child: GestureDetector(
                onTap: (){vm.yeXiuStateViewModel.loginStateViewModel.inputSex(2);},
                child: Container(
                  padding: EdgeInsets.only(left: setRatio(10), top: setRatio(5), bottom: setRatio(11)),
                  margin: EdgeInsets.only(
                      left: setRatio(29), right: setRatio(8)),
                  decoration: ShapeDecoration(
                      shape: UnderlineInputBorder(
                          borderSide: BorderSide(
                              color: sex == 2 ? Color(0xFFEA445A) : Color(0xFFE5E5E5),
                              style: BorderStyle.solid,
                              width: setRatio(1)))),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Image.asset(
                        imageUtilYeXiu(sex == 2 ? 'login/icon_girl_pre@2x':'login/icon_girl_nor@2x'),
                        width: setRatio(25),
                        height: setRatio(28),
                      ),
                      SizedBox(width: setRatio(16),),
                      Text('女生',
                          style: TextStyle(
                            color: sex==2?Color(0xFFEA445A):Color(0xFFC2C2C2),
                            fontSize: setTextSp(15),
                          ))
                    ],
                  ),
                ),
              )
          ),
          Expanded(
              flex: 1,
              child: GestureDetector(
                onTap: (){vm.yeXiuStateViewModel.loginStateViewModel.inputSex(1);},
                child: Container(
                  padding: EdgeInsets.only(left: setRatio(10),top: setRatio(5), bottom: setRatio(11)),
                  margin: EdgeInsets.only(
                      left: setRatio(8), right: setRatio(29)),
                  decoration: ShapeDecoration(
                      shape: UnderlineInputBorder(
                          borderSide: BorderSide(
                              color: sex == 2 ? Color(0xFFE5E5E5) : Color(0xFF0387FF),
                              style: BorderStyle.solid,
                              width: setRatio(1)))),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Image.asset(
                        imageUtilYeXiu(sex==2?'login/icon_boy_nor@2x':'login/icon_boy_pre@2x'),
                        width: setRatio(25),
                        height: setRatio(28),
                      ),
                      SizedBox(width: setRatio(16),),
                      Text('男生',
                          style: TextStyle(
                            color: sex==2?Color(0xFFC2C2C2):Color(0xFF0387FF),
                            fontSize: setTextSp(15),
                          ))
                    ],
                  ),
                ),
              )
          )
        ],
      );
    });
  }
}